<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>example</title>
    <script src="./lib/umd/evaluator.min.js"></script>
    <script>
    </script>
</head>

<body>
    <p>
        <input type="text" value="0.0000434" />
    </p>
    <p>
        <input type="text" value="0.0000434" />
    </p>
    <p>
        <input type="text" value="1212.1212e-1" />
    </p>
    <p>
        <button onclick="add()">+</button>
        <button onclick="subtract()">-</button>
        <button onclick="multiply()">*</button>
        <button onclick="power()">/</button>
        <button onClick="toFixeds()">保留2位小数</button>
        <button onClick="evaluator()">模版计算</button>
    </p>
    <p>
        结果：
    <pre></pre>
    </p>
    <script>
        // window.onload = function () {
        //     console.log("1-2=-1", "subtract=", Evaluator.evaluatorSubtract("1", "2"));
        //     console.log("-1-2=-3", "subtract=", Evaluator.evaluatorSubtract("-1", "2"));
        //     console.log("-1-(-2)=1", "subtract=", Evaluator.evaluatorSubtract("-1", "-2"));
        //     console.log("-3-(-2)=-1", "subtract=", Evaluator.evaluatorSubtract("-3", "-2"));
        //     console.log("-3-2=-5", "subtract=", Evaluator.evaluatorSubtract("-3", "2"));
        //     console.log("3-2=1", "subtract=", Evaluator.evaluatorSubtract("3", "2"));
        // }
        console.log(Evaluator)

        Evaluator.setOptions({ debug: true })

        var num1Dom = document.querySelectorAll("input")[0];
        var num2Dom = document.querySelectorAll("input")[1];
        var num3Dom = document.querySelectorAll("input")[2];
        var pre = document.querySelector("pre");
        function evaluator() {

            pre.innerHTML = "Evaluator.renderTemplate('a+b+c*toFixeds(b-(a+b),2)*d',{ a: '0.003', b: '2', c: '4', d: '98' })：" + Evaluator.renderTemplate('a+b+c*toFixeds(b-(a+b),5+6)*d', { a: '0.003', b: '2', c: '4', d: '98' });

        }
        function toFixeds() {
            pre.innerHTML = "Evaluator.toFixeds(" + num1Dom.value + ")：" + Evaluator.toFixeds(num1Dom.value);
        }

        function add() {
            var num1 = num1Dom.value;
            var num2 = num2Dom.value;
            var num3 = num3Dom.value;
            pre.innerHTML = "Evaluator.evaluatorAdd( " + num1 + "," + num2 + ")：" + Evaluator.evaluatorAdd(num1, num2,);
        }
        function multiply() {
            var num1 = num1Dom.value;
            var num2 = num2Dom.value;
            var num3 = num3Dom.value;
            pre.innerHTML = "Evaluator.evaluatorMultiply( " + num1 + "," + num2 + ")：" + Evaluator.evaluatorMultiply(num1, num2,);
        }
        function subtract() {
            var num1 = num1Dom.value;
            var num2 = num2Dom.value;
            var num3 = num3Dom.value;
            pre.innerHTML = "Evaluator.evaluatorSubtract(" + num1 + "," + num2 + ")：" + Evaluator.evaluatorSubtract(num1, num2);
        }
        function power() {
            var num1 = num1Dom.value;
            var num2 = num2Dom.value;
            var num3 = num3Dom.value;
            pre.innerHTML = "Evaluator.evaluatorDivide(" + num1 + "," + num2 + ")：" + Evaluator.evaluatorDivide(num1, num2);
        }
    </script>
</body>

</html>